//
//  AppDelegate+KZAppDelegateConfig.m
//  lg_zhinengbeikao_english
//
//  Created by 朱凯 on 2018/12/29.
//  Copyright © 2018 zhukai. All rights reserved.
//

#import "AppDelegate+KZAppDelegateConfig.h"

#import "KZTabBarController.h"
#import "KZGuideViewController.h"

@implementation AppDelegate (KZAppDelegateConfig)

- (void)addScrollAdaption {
    
    UITableView.appearance.tableFooterView = UIView.new;
    
    if (@available(ios 11.0,*)) {
        UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        UITableView.appearance.estimatedRowHeight = 0;
        UITableView.appearance.estimatedSectionFooterHeight = 0;
        UITableView.appearance.estimatedSectionHeaderHeight = 0;
    }
}


- (void)addKouYuSDK {
    
    KYStartEngineConfig *startEngineConfig = [[KYStartEngineConfig alloc] init];
    startEngineConfig.appKey = @"148757611600000f";
    startEngineConfig.secretKey = @"2d5356fe1d5f3f13eba43ca48c176647";
    //初始化引擎
    [[KYTestEngine sharedInstance] initEngine:KY_CloudEngine startEngineConfig:startEngineConfig finishBlock:^(BOOL isSuccess) {
        if (isSuccess) {
            NSLog(@"口语引擎初始化成功");
        } else {
            NSLog(@"口语引擎初始化失败");
        }
    }];
}
- (void)addAFNetListening {
    
    AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
    [manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        switch (status) {
            case AFNetworkReachabilityStatusReachableViaWiFi:
                NSLog(@"切换到WIFI网络");
                break;
            case AFNetworkReachabilityStatusReachableViaWWAN:
                NSLog(@"切换到3/4G网络");
                break;
            case AFNetworkReachabilityStatusNotReachable:
                NSLog(@"网络连接异常");
                break;
            case AFNetworkReachabilityStatusUnknown:
                NSLog(@"未知网络");
                break;
            default:
                break;
        }
    }];
    [manager startMonitoring];
}

- (void)addKeyboardManager {
    
    [IQKeyboardManager sharedManager].enable = true;
}

- (void)enterSystem {
    
//    if(true) {
    if([KZGuideViewController needShowGuide]) {
        self.window.rootViewController = [KZGuideViewController appGuideVCWithImageNames:nil imageURLs:nil enterBlock:^{
            [self enterSystemWithTransition:YES];
        } configuration:^(UIButton *enterButton, UIButton *timerButton) {
            
        } timerDuration:3];
    } else {
        [self enterSystemWithTransition:NO];
    }
}
- (void)enterSystemWithTransition:(BOOL)transition {
    
    self.window.rootViewController = [[KZTabBarController alloc] init];
    if (transition) {
        [self.window.layer transitionWithAnimType:TransitionAnimTypeFade subType:TransitionSubtypesFromRight curve:TransitionCurveDefault duration:1.5f];
    }
}

@end
